/*
 * @Author: Tendo 
 * @Date: 2021-09-29 19:25:30 
 * @param {string} s
 * @return {boolean}
 * @desc 简化版
 */

// 简化版本
var isValid = function(s) {
    const stack = [],
        map = {
            "(":")",
            "{":"}",
            "[":"]"
        }; // 存的是key 和 value
    for (const x of s) {
        if (x in map) {
            stack.push(x);
            continue;
        }
        if (map[stack.pop()] !== x) return false;
    }
    return !stack.length;
};
